<template>
	<view class="myBankCard">
		<view class="list">
			<view class="item" v-for="(item,index) in bankList" :key="index" :class="index==0?'bg1':index==1?'bg2':'bg3'" >
				<view class="bank flex-align-center">
					<image src="" class="icon" mode=""></image>
					<view class="name">{{item.gsBankName}}</view>
					<view class="flex-aj-center unbind" @click.stop="unbind(item.hhrBankId)" >
						解绑此卡
					</view>
				</view>
				<view class="number flex-align-center">
					<view>{{item.cardNumber.slice(0,4)}}</view>
					<view>****</view>
					<view>****</view>
					<view>****</view>
					<view>{{item.cardNumber.slice(-4)}}</view>
				</view>
			</view>
			<view class="flex-aj-center" v-if="bankList.length==0" >
				<image src="../../static/images/no-data.png" mode=""></image>
			</view>
		</view>
		<view class="addCard flex-aj-center" @click="addCard" >
			<image src="https://cdcrm.oss-cn-hangzhou.aliyuncs.com/cdcrm/business/2024/4/62871714203004706.png" mode=""></image>添加银行卡
		</view>
	</view>
</template>

<script>
	import {
		getBankList,
		delCard
	} from "@/api/user.js"
	import { mapGetters } from "vuex";
	export default {
		data(){
			return{
				bankList:[]
			}
		},
		computed: {
			...mapGetters(['isLogin', 'uid']),
		},
		onShow() {
			this.getList()
		},
		methods:{
			getList(){
				getBankList({
					pageNum:1,
					pageSize:1000,
					// clientUserId:this.uid
				}).then(res=>{
					this.bankList = res.data.records
				})
			},
			addCard(){
				uni.navigateTo({
					url:'./addCard'
				})
			},
			unbind(id){
				let that = this;
				uni.showModal({
					title:'提示',
					content:'确认解绑此卡嘛？',
					success(res) {
						if(res.confirm){
							delCard(id).then(res=>{
								that.$util.Tips({
									title:'解绑成功',
									icon:"none"
								})
								that.getList()
							})
						}
					}
				})
			}
		}
	}
</script>
<style>
	page{
		background-color: #fff;
	}
</style>
<style lang="scss" scoped >
	.myBankCard{
		padding: 24rpx;
	}
	
	.addCard{
		width: 100%;
		height: 96rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		border: 2rpx dashed #EBEBEB;
		font-family: PingFangSC;
		font-weight: 500;
		font-size: 32rpx;
		color: #292929;
		line-height: 32rpx;
		image{
			width: 32rpx;
			height: 32rpx;
			margin-right: 8rpx;
		}
	}
	
	.list{
		.item{
			margin-bottom: 24rpx;
			width: 100%;
			height: 256rpx;
			background-size: cover;
			padding: 56rpx 32rpx;
			
			&.bg1{
				background-image: url(https://cdcrm.oss-cn-hangzhou.aliyuncs.com/cdcrm/business/2024/4/27751714185120587.png);
			}
			
			&.bg2{
				background-image: url(https://cdcrm.oss-cn-hangzhou.aliyuncs.com/cdcrm/business/2024/4/73001714203240396.png);
			}
			
			&.bg3{
				background-image: url(https://cdcrm.oss-cn-hangzhou.aliyuncs.com/cdcrm/business/2024/4/66741714203254253.png);
			}
			
			.bank{
				margin-bottom: 48rpx;
				.icon{
					width: 64rpx;
					height: 64rpx;
					border-radius: 50%;
					margin-right: 24rpx;
				}
				.name{
					font-family: PingFangSC;
					font-weight: 500;
					font-size: 32rpx;
					color: #FFFFFF;
					line-height: 32rpx;
					text-align: left;
					font-style: normal;
					flex: 1;
				}
				.unbind{
					width: 144rpx;
					height: 56rpx;
					background: rgba(255,255,255,0.12);
					border-radius: 28rpx;
					font-family: PingFangSC;
					font-weight: 600;
					font-size: 24rpx;
					color: #FFFFFF;
					line-height: 24rpx;
				}
			}
			.number{
				>view{
					width: 110rpx;
					height: 32rpx;
					font-family: D-DINExp;
					font-weight: bold;
					font-size: 32rpx;
					color: #FFFFFF;
					line-height: 32rpx;
					text-align: center;
					font-style: normal;
					margin-right: 34rpx;
					&:last-child{
						margin-right: 0;
					}
				}
			}
		}
	}
</style>